package cn.edu.ujn.booksshop.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.edu.ujn.booksshop.dao.Order;
import cn.edu.ujn.booksshop.dao.OrderMapper;
import cn.edu.ujn.util.Page;
@Service
@Transactional
public class OrderServiceImpl implements OrderService {
	@Autowired
	private OrderMapper orderDao;
	
	@Override
	public Order findOrder(Integer orderid) {
		Order selectByPrimaryKey = this.orderDao.selectByPrimaryKey(orderid);
		return selectByPrimaryKey;
	}

	@Override
	public int add(Order row) {
		int insert = this.orderDao.insert(row);
		return insert;
	}

	@Override
	public int delete(Integer orderid) {
		int d = this.orderDao.deleteByPrimaryKey(orderid);
		return d;
	}

	@Override
	public int update(Order row) {
		int key = this.orderDao.updateByPrimaryKey(row);
		return key;
	}

	
	@Override
	public Page<Order> selectAll(Integer page, Integer rows) {
		List<Order> list = this.orderDao.selectAll((page-1)*rows,rows);
		Page<Order> pages = new Page<Order>();
		pages.setPage(page);
		pages.setRows(list);
		pages.setSize(rows);
		pages.setTotal(100);
		return pages;
	}

	@Override
	public int updateByPrimaryKeySelective(Order row) {
		int selective = this.orderDao.updateByPrimaryKeySelective(row);
		return selective;
	}

}
